/* eslint-disable no-shadow */
export function count({ search }) {
  return RSocket.rr({
    route: 'ccorders.count',
    args: { search },
  });
}

export function search({ search, pg }) {
  return RSocket.rs({
    route: 'ccorders',
    args: { search, pg, sort: ['crDate;desc'] },
  });
}

export function ordersSearchCount({ search }) {
  return RSocket.rr({
    route: 'orders.search.count',
    args: { search: { ...search, orderType: 1 } },
  });
}

export function ordersSearch({ search, pg }) {
  return RSocket.rs({
    route: 'orders.search',
    args: { search: { ...search, orderType: 1 }, pg, sort: ['upDate;desc'] },
  });
}

export function get(id) {
  return RSocket.rr({
    route: `ccorders.${id}`,
  });
}

/**
 * @func 获取任务信息
 */
export function getTaskInfo(id) {
  return RSocket.rr({
    route: `tasks.${id}`,
  });
}

/**
 * @func 获取换乘订单信息
 */
export function getTransferTaskInfo(orderId) {
  return RSocket.rr({
    route: `ccorders.${orderId}.transfer.line`,
  });
}


export function update(order) {
  return RSocket.rr({
    route: 'ccorders.update',
    data: order,
  });
}

/**
 * @func 日志流水分页条件查询
 * @param {}
 */
export function getLogs(search) {
  return RSocket.rs({
    route: 'logs',
    args: {
      search,
      pg: { page: 0, size: 100, sort: ['ts;desc'] },
    },
  });
}

/**
 * 订单发起申请退款
 * @param {*} id 订单id
 * @param {*} data 请求数据
 * @returns true
 */
export function orderSponsorRefund(id, data, args) {
  return RSocket.rr({
    route: `orders.${id}.application.refund`,
    args: {
      ...args,
    },
    data: [
      ...data,
    ],
  });
}

/**
 * 订单发起线下支付 后端中间件
 * @param {*} data 请求数据
 * @returns true
 */
export function orderCreateOffline(data) {
  return RSocket.rr({
    route: 'cbv.offline.add.refund',
    data: {
      ...data,
    },
  });
}

/**
 * 获取该车票下的订单信息
 * @param {*} id 订单id
 * @returns true
 */
export function getIdRefund(id) {
  return RSocket.rs({
    route: `orders.${id}.get.refund`,
  });
}

/**
 * 取消订单中的申请退款
 * @param {*} data 请求参数
 * @returns true
 */
export function orderCancelRefund(data) {
  return RSocket.rr({
    route: 'orders.cancel.refund',
    args: {
      ...data,
    },
  });
}

/**
 * 提交本次退款申请
 * @param {*} data 请求参数
 * @returns true
 */
export function orderCommitRefund(args) {
  return RSocket.rr({
    route: 'orders.commit.refund',
    args: {
      ...args,
    },
  });
}

/**
 * @func 主动取消包车订单
 */
export function cancel(id) {
  return RSocket.rr({
    route: `ccorders.${id}.cancel`,
  });
}

/**
 * @func 通过日志流水获取任务时刻
 */
export function getLogTime(taskOrderId, username) {
  return RSocket.rr({
    route: `logs.${taskOrderId}.get.time`,
    args: { username },
  });
}

/**
 * @func 搜索评论的数量
 */
export function commentCount(search) {
  return RSocket.rr({
    route: 'comments.count',
    args: { search },
  });
}

/**
 * @func 搜索评论
 */
export function commentSearch(search, pg) {
  return RSocket.rs({
    route: 'comments',
    args: { search, pg, sort: ['crDate;desc'] },
  });
}

/**
 * @func 查询指定商户信息
 */
export function getMerchants(id) {
  return RSocket.rr({
    route: `biz.merchants.${id}`,
  });
}

/**
 * 查询分账方
 * @param {*} orderId 订单id
 * @param {*} type 是否ab段
 * @returns true
 */
export function getAccount(orderId, type) {
  return RSocket.rs({
    route: `orders.${orderId}.account.info`,
    args: {
      directRoute: type,
    },
  });
}

/**
 * 查询换乘线路
 * @param {*} orderId 订单id
 * @param {*} type 是否ab段
 * @returns true
 */
export function getTransferLine(id) {
  return RSocket.rr({
    route: `ccorders.${id}.transfer.line`,
  });
}

/**
 * 获取该车票下的订单信息
 * @param {*} id 订单id
 * @returns true
 */
export function getOrderTicket({ search, pg }) {
  return RSocket.rs({
    route: 'cbv.applications',
    args: {
      search: {
        ...search,
        orderType: '1',
      },
      pg,
    },
  });
}

/**
 * 获取该车票下的订单信息
 * @param {*} id 订单id
 * @returns true
 */
export function getOrderTicketCount({ search }) {
  return RSocket.rr({
    route: 'cbv.applications.count',
    args: {
      search: {
        ...search,
        orderType: '1',
      },
    },
  });
}

/**
 * 修改订单中的申请退款
 * @param {*} data 请求参数
 * @returns true
 */
export function orderRefundUpdate(data) {
  return RSocket.rr({
    route: 'cbv.applications.update',
    data: {
      ...data,
    },
  });
}


/**
 * 获取订单优惠信息
 * @param {*} id
 * @returns
 */
export function getOrderDiscountInfo(args) {
  return RSocket.rs({
    route: 'cbv.applications.order.discount.info',
    args: {
      ...args,
    },
  });
}

/**
 * 取消订单
 */
export function orderCancel(args) {
  return RSocket.rr({
    route: 'orders.cancel',
    args,
  });
}

/**
 * 开启分账
 */
export function orderEnableShare(args) {
  return RSocket.rr({
    route: 'orders.enable.order.share',
    args,
  });
}

/**
 * 获取收款方
 */
export function getOrderPayee(args) {
  return RSocket.rr({
    route: 'pay.trans.payee',
    args,
  });
}

/**
 * 获取收款方
 */
export function offlineAddPay(args) {
  return RSocket.rr({
    route: 'cbv.offline.add.pay',
    data: { ...args },
  });
}
